import { ObjCreate } from "../../common/ObjCreate";
import { TitleItem } from "../../common/item/TitleItem";
import { Language } from "../../../../../extend/language/Language";
import { ObjTeamCreate } from "../../common/ObjTeamCreate";
import { MarryGuestCell } from "../cellRenderer/MarryGuestCell";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SMarryGuestInfos } from "../../../../../Message/Public/SMarryGuestInfos";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
type int = number;
//class MarrySceneGuestPanel
    
    export  class MarrySceneGuestPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.createChildren();
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        /* internal  */createChildren(): void
        {
            ObjCreate.createBg(0, 0, 377, 316, this);
            var loc1=new Vector.<TitleItem>();
            loc1.push(new TitleItem(Language.getString(43538), 130));
            loc1.push(new TitleItem(Language.getString(43539), 120));
            loc1.push(new TitleItem(Language.getString(43540), 120));
            var loc2=ObjTeamCreate.createTitles(loc1);
            ObjCreate.setObjAttri(loc2, 10, 7, -1, -1, this);
            this._guestTileList = ObjCreate.createTileList(8, 25, 360, 290, this);
            this._guestTileList.columnWidth = 360;
            this._guestTileList.rowHeight = 29;
            this._guestTileList.setStyle("cellRenderer", MarryGuestCell);
            this._pageSelecter = ObjCreate.createPageSelecter(128, 319, this, PageSelecter.CompleteMode);
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onPageChange);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryGetSceneGuestList));
            return;
        }

        public updateSceneGuestInfos(arg1: SMarryGuestInfos): void
        {
            this._pageSelecter.maxPage = Math.ceil(arg1.guests.length / this._pageSize);
            this._pageSelecter.currentPage = 1;
            this._marryGuestInfos = arg1;
            this.updateGuestList();
            return;
        }

        /* internal  */onPageChange(arg1: Object /* flash.events.Event */): void
        {
            this.updateGuestList();
            return;
        }

        /* internal  */updateGuestList(): void
        {
            var loc1=new Array<any>();
            var loc2=(this._pageSelecter.currentPage - 1) * this._pageSize;
            var loc3=Math.min(this._pageSelecter.currentPage * this._pageSize, this._marryGuestInfos.guests.length);
            var loc4=loc2;
            while (loc4 < loc3) 
            {
                loc1.push(this._marryGuestInfos.guests[loc4]);
                ++loc4;
            }
            this._guestTileList.dataProvider = new DataProvider(loc1);
            this._guestTileList.drawNow();
            return;
        }

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_guestTileList: GTileList;

        /* internal */ /* var */_pageSize: int=10;

        /* internal */ /* var */_marryGuestInfos: SMarryGuestInfos;
    }
